<#assign base=request.contextPath />
<#if paymentDO?? && (paymentDO.id)!=0>
	<#assign leafLabel="编辑其他支出">
	<#else>
	<#assign leafLabel="新增其他支出">
</#if>
<!DOCTYPE html>
<html lang="en">
<head>
	<link rel="stylesheet" href="${base}/static/assets/css/chosen.css" />
	<#include "/commons/headImport.ftl">
</head>
<body>
	<div class="main-container" id="main-container">
		<script type="text/javascript">
			try{ace.settings.check('main-container' , 'fixed')}catch(e){}
		</script>

		<div class="main-container-inner">
			<div class="main-content">
				<div class="page-content">
					<div class="page-header">
						<h4>${leafLabel!'--'}</h4>
					</div><!-- /.page-header -->

					<form class="form-horizontal" name="formName" method="post">
					<input type="hidden" value="${paymentDO.contractId!0}" name="contractId" id="contractId"/>
					<input type="hidden" value="${base}" id="context_hidden_id"/>
					<input type="hidden" value="${paymentDO.id!0}" name="id" id="id"/>
					<div class="row">
						<div class="col-xs-12">
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right" for="form-field-2">日期</label>
								<div class="col-sm-4">
									<div class="row">
	                                    <div class="col-xs-12">
	                                        <div class="input-group input-group-sm">
	                                            <input type="text" id="buyDate" readonly="true" class="form-control date-picker" name="buyDate" 
	                                            	value="${(paymentDO.buyDate?string("yyyy-MM-dd"))!''}" data-date-format="yyyy-mm-dd"/>
	                                            <span class="input-group-addon"><i class="icon-calendar"></i></span>
	                                        </div>
	                                    </div>
	                            	</div>
								</div>
								<div class="help-block col-xs-12 col-sm-reset inline"></div>
							</div>
							<div class="space-4"></div>
							
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right" for="form-field-2">名称</label>
								<div class="col-sm-4">
									<@spring.formInput "paymentDO.name" "class='col-sm-12'"/>
								</div>
								<div class="help-block col-xs-12 col-sm-reset inline"></div>
							</div>
							<div class="space-4"></div>

							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right" for="form-field-2">金额</label>
								<div class="col-sm-4">
									<@spring.formInput "paymentDO.pageAmount" "class='col-sm-8'"/>
								</div>
								<div class="help-block col-xs-12 col-sm-reset inline"></div>
							</div>
							<div class="space-4"></div>

							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right">原因</label>
								<div class="col-sm-4">
									<@spring.formTextarea "paymentDO.remark" "class='col-sm-12' rows='4'"/>
								</div>
								<div class="help-block col-xs-12 col-sm-reset inline"></div>
							</div>
							<div class="space-4"></div>
						</div><!-- /.col -->
					</div><!-- /.row -->
				</form>
			</div><!-- /.page-content -->
		</div><!-- /.main-content -->
	</div><!-- /.main-container-inner -->
</div><!-- /.main-container -->
<div class="hr hr32 hr-dotted"></div>
<div class="clearfix">
	<label class="col-sm-2 control-label no-padding-right"></label>
	<div class="col-md-offset-3 col-md-9">
		<button class="btn btn-xs btn-info" type="button" id="add_id"
			url="<#if paymentDO??&&paymentDO.id!=0>${base}/payment/edit<#else>${base}/payment/add</#if>">
			<i class="icon-save bigger-110"></i>保存
		</button>
		<button class="btn btn-xs" type="reset" id="return_id">
			<i class="icon-reply bigger-110"></i>关闭
		</button>
	</div>
</div>
	
<#include "/commons/footJs.ftl">
<script src="${base}/static/assets/js/date-time/bootstrap-datepicker.min.js"></script>
<script src="${base}/static/assets/js/date-time/bootstrap-datepicker.zh-CN.js"></script>
<script src="${base}/static/assets/js/chosen.jquery.min.js"></script>
<script src="${base}/static/layer/layer.js"></script>
<script type="text/javascript">
	jQuery(function($) {
		var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
	   	$("#add_id").click(function(){
	   		var url=$(this).attr("url");
	   		
	   		var contractId=$("#contractId").val();
	   		var buyDate= $("#buyDate").val();
	   		var name = $("#name").val();
	   		var amount=$("#pageAmount").val();
	   		if(buyDate==""){
	   			layer.msg('日期必须填写');
	   			return false;
	   		}
	   		if(name==""){
	   			layer.msg('姓名必须填写');
	   			return false;
	   		}
	   		if(amount==""){
	   			layer.msg('金额必须填写');
	   			return false;
	   		}
	   		layer.load(2);
			$.post(
				url, 
				{
				"id":$("#id").val(),
				"contractId": contractId, 
				"buyDate": buyDate,
				"name":name,
				"pageAmount":amount,
				"remark":$("#remark").val(),
				"type":20
				},
			  	function(data){
			     if(data.success){
			     	layer.closeAll('loading');
			     	parent.layer.close(index);
			     	window.parent.location.reload(); //刷新父页面
			     }else{
			     	var json = JSON.stringify(data.msg);
			     	layer.msg(json);
			     	layer.closeAll('loading');
			     }
			});
	   	});
	   		
	   $("#return_id").click(function(){
			parent.layer.close(index);
	   });
	   
	   $('.date-picker').datepicker({
	   		language: 'zh-CN',//选择语言
			autoclose: true,
			todayHighlight: true
		})
	});
</script>
</body>
</html>
